home *** CD-ROM | disk | FTP | other *** search
/ Strip Blackjack / Strip Blackjack - Volume 1.iso / pc / imonag.dxr / 00055.ls < prev    next >
Encoding:
Text File  |  1994-12-07  |  3.8 KB  |  184 lines

  1. on start
  2.   global S, dlast, ulast, matrix, umax, dmax, uoffset, doffset, totalu, totald, exu, totalux, stay, edx, totaldx, over
  3.   if S = 8 then
  4.     play movie "IMONA8.DXR"
  5.   end if
  6.   set over to 0
  7.   set stay to 0
  8.   set exu to 0
  9.   set edx to 0
  10.   set totalux to 0
  11.   set totaldx to 0
  12.   set totalu to 0
  13.   set totald to 0
  14.   set uoffset to 1
  15.   set doffset to 10
  16.   set umax to []
  17.   set dmax to []
  18.   repeat with i = 2 to 22
  19.     puppetSprite(i, 1)
  20.   end repeat
  21.   puppetSprite(44, 1)
  22.   set the visible of sprite 44 to 0
  23.   repeat with i = 4 to 10
  24.     set the visible of sprite i to 0
  25.   end repeat
  26.   repeat with i = 13 to 19
  27.     set the visible of sprite i to 0
  28.   end repeat
  29.   repeat with i = 25 to 28
  30.     set the visible of sprite i to 0
  31.   end repeat
  32.   repeat with i = 20 to 22
  33.     set the visible of sprite i to 1
  34.   end repeat
  35.   set ulast to 0
  36.   set dlast to 0
  37.   set matrix to []
  38.   repeat with i = 1 to 52
  39.     add(matrix, i)
  40.   end repeat
  41.   puppetSprite(36, 1)
  42.   set the visible of sprite 36 to 1
  43.   updateStage()
  44.   addu()
  45.   addu()
  46.   addd()
  47.   addd()
  48. end
  49.  
  50. on addu
  51.   global umax, dmax, matrix, ulast, dlast, uoffset, doffset, totalu, totald, exu, totalux, Y
  52.   set x to 0
  53.   repeat while getOne(matrix, x) = 0
  54.     set x to random(52)
  55.   end repeat
  56.   deleteAt(matrix, getPos(matrix, x))
  57.   set ulast to ulast + 1
  58.   set the castNum of sprite (uoffset + ulast) to x
  59.   set the visible of sprite (uoffset + ulast) to 1
  60.   add(umax, x)
  61.   set totalu to totmax(umax)
  62.   if cvalue(x) = 1 then
  63.     set exu to exu + 10
  64.   end if
  65.   set totalux to totalu + exu
  66.   updateStage()
  67.   delx()
  68. end
  69.  
  70. on addd
  71.   global umax, dmax, matrix, ulast, dlast, uoffset, doffset, totalu, totald, stay, edx, totaldx, Y
  72.   set x to 0
  73.   repeat while getOne(matrix, x) = 0
  74.     set x to random(52)
  75.   end repeat
  76.   deleteAt(matrix, getPos(matrix, x))
  77.   set dlast to dlast + 1
  78.   if count(dmax) > 0 then
  79.     set the castNum of sprite (doffset + dlast - 1) to getAt(dmax, count(dmax))
  80.     if cvalue(getAt(dmax, count(dmax))) = 1 then
  81.       set edx to edx + 10
  82.     end if
  83.   end if
  84.   set totald to totmax(dmax)
  85.   set totaldx to totmax(dmax) + edx
  86.   if (totaldx <= 16) or ((totald <= 16) and (totaldx > 21)) then
  87.     set the castNum of sprite (doffset + dlast) to 53
  88.     set the visible of sprite (doffset + dlast) to 1
  89.     add(dmax, x)
  90.   end if
  91.   updateStage()
  92. end
  93.  
  94. on cvalue x
  95.   set yu to the name of cast x
  96.   set yi to char 2 of yu
  97.   if voidp(value(yi)) then
  98.     return 10
  99.   else
  100.     return value(yi)
  101.   end if
  102. end
  103.  
  104. on delx
  105.   global umax, dmax, matrix, ulast, dlast, uoffset, doffset, totalu, totald, totalux
  106.   if totalu > 21 then
  107.     lose()
  108.     exit
  109.   end if
  110.   if (totalu = 21) or (totalux = 21) then
  111.     win()
  112.     exit
  113.   end if
  114.   if count(umax) = 5 then
  115.     win()
  116.     exit
  117.   end if
  118. end
  119.  
  120. on win
  121.   global over, S
  122.   set over to 1
  123.   set the visible of sprite 36 to 0
  124.   go(11)
  125. end
  126.  
  127. on lose
  128.   global over
  129.   set over to 1
  130.   set the visible of sprite 20 to 0
  131.   set the visible of sprite 21 to 0
  132.   go(12)
  133. end
  134.  
  135. on totmax x
  136.   set yu to 0
  137.   repeat with i in x
  138.     set yu to yu + cvalue(i)
  139.   end repeat
  140.   return yu
  141. end
  142.  
  143. on stay
  144.   global umax, dmax, matrix, ulast, dlast, uoffset, doffset, totalu, totald, stay, totalux, totaldx, edx, exu, totalub, totaldb
  145.   set stay to 0
  146.   repeat while (totaldx <= 16) or ((totald <= 16) and (totaldx > 21))
  147.     addd()
  148.   end repeat
  149.   if totald > 21 then
  150.     win()
  151.     exit
  152.   end if
  153.   if (totald = 21) or (totaldx = 21) then
  154.     lose()
  155.     exit
  156.   end if
  157.   calcbest()
  158.   if totalub >= totaldb then
  159.     win()
  160.   else
  161.     lose()
  162.   end if
  163. end
  164.  
  165. on calcbest
  166.   global totald, totalu, totaldx, totalux, edx, exu, totaldb, totalub
  167.   set totaldb to totaldx
  168.   set totalub to totalux
  169.   repeat with i = 1 to edx / 10
  170.     if totaldb > 21 then
  171.       set totaldb to totaldb - 10
  172.       next repeat
  173.     end if
  174.     exit repeat
  175.   end repeat
  176.   repeat with i = 1 to exu / 10
  177.     if totalub > 21 then
  178.       set totalub to totalub - 10
  179.       next repeat
  180.     end if
  181.     exit repeat
  182.   end repeat
  183. end
  184.